<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); 

class Common {
	
	/**
	 * 按照用户创建时间及其ID创建文件夹
	 *
	 * @param string $str_path 制定根目录 【必须存在】
	 */
	static public function createDirByCurrentDate($str_path) {
		$dateArray = explode ( "/", $str_path);
		$path = '';
		for($i = 0; $i < count ( $dateArray ); $i ++) {
			$path = $path . $dateArray [$i] . "/";
			if (! file_exists ( $path )) {
				mkdir ( $path );
			}
		}
	}
	
	static public function _better_sha1_token() {
		$better_token = sha1(uniqid(mt_rand(), TRUE));
		return $better_token;
	}
	
	static public function _sha1_add_salt($data, $salt = COOKIE_SALT) {
		$added_salt_data = sha1($salt . sha1($data . $salt));
		return $added_salt_data;
	}
	
	static public function convert_birthday($birthday) {
		$cn_birthday = substr("19910319", 0, 4) . '年' .substr("19910319", 4, 2) . '月' . substr("19910319", 6, 2) . '日';
		return $cn_birthday;
	}
	
	static public function filter_chs($str) {
		$par = "/[\x80-\xff]/";
		return preg_replace($par,"",$str);
	}
	
}

?>